<template>
    <div class="clearfix head-search-content-container" >
        <div class="head-search-content-area">
            <!--标题 公司名称-->
            <div class="head-search-title">
                慧宇猎头服务平台
            </div>
            <!--搜索条-->
            <div class="head-search-content">
                <el-input
                          clearable
                          placeholder="请输入内容"
                          v-model="queryCondition.workJobName"
                          class="input-with-select"
                >
                    <el-select
                            style="width: 130px;background: #fff"
                            slot="prepend"
                            v-model="selectInfo"
                            placeholder="请选择"
                    >
                        <el-option label="找工作" value="1"></el-option>
<!--                        <el-option label="找企业" value="2"></el-option>
                        <el-option label="找人才" value="3"></el-option>
                        <el-option label="找猎头" value="4"></el-option>-->
                    </el-select>
                    <el-button slot="append" icon="el-icon-search"
                        @click="searchAll()"
                    ></el-button>
                </el-input>
            </div>
            <!--按钮 -->
            <div class="head-search-buton">
                    <el-button type="primary"
                               round
                               @click="isAuths('companys:company:save')"
                               >职位发布
                    </el-button>
                &nbsp;

                    <el-button
                            type="warning"
                            round
                            @click="isAuthsResume('resumes:resume:publish')">
                        简历登记
                    </el-button>

            </div>
        </div>
    </div>
</template>

<script>
    import {isAuth} from "@/utils/index"
    import workjobApi from "@/api/workjobs/workjobApi";
    export default {
        name: "main-header-seacher",
        data(){
            return{
                input1: '',
                input2: '',
                input3: '',
                select: '',
                selectInfo:'1',
                queryCondition:{
                    workJobName: undefined
                }
            }
        },
        methods:{
            //全局搜索
            searchAll(){

                const token = this.$cookie.get('client_token')
                if (!token){
                    this.$message({
                        type:'warning',
                        message:'您好，请先登录！！！'
                    })
                    return;
                }



                if (this.selectInfo == '1'){
                    //console.log("this. queryCondition ===>",this.queryCondition)
                    if (this.queryCondition.workJobName!=undefined){
                        workjobApi.showPostion('1','5',this.queryCondition)
                            .then(data => {
                                console.log("data ==== 123 ====",data)
                                if (data.data.code === 0){
                                    this.$router.push(
                                        {
                                            path: '/home/headhuntingCompany/1',
                                            query:{
                                                pageDataCompanyNotIsUrgency:JSON.stringify(data.data.pageDataCompanyNotIsUrgency),
                                                pageDataCompanyNotIsUrgencyTotal:data.data.pageDataCompanyNotIsUrgencyTotal,
                                                conditionQuery:JSON.stringify(this.queryCondition)
                                            }
                                        }
                                    )
                                }
                            })
                            .catch(err => {
                                Promise.reject(err)
                            })
                    }else{
                        workjobApi.showPostion('1','5',this.queryCondition)
                            .then(data => {
                                console.log("data ==== 123 ====",data)
                                if (data.data.code === 0){
                                    this.$router.push(
                                        {
                                            path: '/home/headhuntingCompany/1',
                                        }
                                    )
                                }
                            })
                            .catch(err => {
                                Promise.reject(err)
                            })
                    }

                }
            },

            //简历登记权限
            isAuthsResume(value){
                const token = this.$cookie.get('client_token')
                if (!token){
                    this.$message({
                        type:'warning',
                        message:'您好，请先登录！！！'
                    })
                    return;
                }
                const isAuths = isAuth(value)
                if (!isAuths){
                    this.$message({
                        type:'warning',
                        message:'抱歉,请使用求职者用户操作'
                    })
                    return
                }else{
                    this.$router.replace("/home/resumeRegister")
                }
            },
            //职位发布权限
            isAuths(value){
                const token = this.$cookie.get('client_token')
                if (!token){
                    this.$message({
                        type:'warning',
                        message:'您好，请先登录！！！'
                    })
                    return;
                }
                const isAuths = isAuth(value)
                if (!isAuths){
                    this.$message({
                        type:'warning',
                        message:'抱歉,请使用企业用户操作'
                    })
                    return
                }else{
                    this.$router.replace("/home/companyCenter/workjobCreateInfo")
                }
            },
        }
    }
</script>

<style scoped>
    /*清除浮动*/
    /*.clearfix:before,*/
    /*.clearfix:after{*/
    /*    content:"";*/
    /*    display:table*/
    /*}*/


    .el-select .el-input {
        width: 130px;
    }
    .input-with-select .el-input-group__prepend {
        background-color: #fff;
    }

    .head-search-content-container{
        width: 1360px;
        height: 60px;
        line-height: 60px;
        /*background-color: indianred;*/
        margin: 0 auto;
    }

    /*搜索内容开始*/
    .head-search-content-area{
        margin: 0 auto;
    }
    /*title 的位置*/
    .head-search-title{
        width: 200px;
        height: 60px;
        line-height: 60px;
        float: left;
        font-size: 25px;
        font-weight: bold;
        margin-left: 20px;
    }
    /*搜索框的位置*/
    .head-search-content{
        width: 750px;
        height: 60px;
        line-height: 60px;
        margin-left: 80px;
        /*background-color: lightcyan;*/
        float: left;
    }
    /*按钮的位置*/
    .head-search-buton
    {
        float: left;
        display: inline-block;
        width: 250px;
        height: 60px;
        line-height: 60px;
        margin-left: 40px;
    }

    /*head-top 按钮位置*/
    .head-top .button-left{
        margin-left: 10px;
    }
    .head-top  .button-right{
        display: block;
        margin-left: 950px;
    }
    .el-header {
        background-color: #FFF;
    }
</style>
